package com.luych.oauth2Module.service;

import com.luych.oauth2Module.entitey.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class UserService {

    private final RestTemplate restTemplate;

    @Autowired
    public UserService(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    public UserInfo getUserByLoginName(String loginName) {
        return restTemplate.getForObject("http://USERCENTER/user/by/loginName/{loginName}", UserInfo.class, loginName);
    }
}
